<template>
  <basic-container>
    <avue-crud v-bind="bindVal"
               v-on="onEvent"
               :page.sync="page"
               v-model="startForm">
      <!-- 菜单按钮 -->
      <template slot="menuLeft">
        <el-button type="primary" v-if="getBtnPermission('downloadTemplateBtn',null,null,false)"
                   @click="downloadTemplate()" size="small">下载导入模板
        </el-button>
        <el-button type="primary" v-if="getBtnPermission('exportExcelBtn',null,null,false)" @click="handlerImportExcel"
                   size="small">导入excel
        </el-button>
        <el-button type="primary" v-if="getBtnPermission('importExcelBtn',null,null,false)" @click="downloadexportExcel()"
                   size="small">导出excel
        </el-button>
      </template>
      <template v-for="(column,index) in columns" :slot="column.prop" slot-scope="{type,size,row}">
        <component :is="column.columnComponent" :row="row" :column="column" :rowKey="column.prop"
                   :key="row.id+':'+index"></component>
      </template>
      <template slot-scope="{type,size,row}" slot="menuBtn">
        <el-dropdown-item icon="el-icon-edit" :size="size" @click.native="editUserRole(row)" :type="type">用户角色
        </el-dropdown-item>
        <el-dropdown-item icon="el-icon-edit" :size="size" @click.native="editUserPwd(row)" :type="type">密码重置
        </el-dropdown-item>
      </template>
    </avue-crud>
    <select-user-roles ref="selectUserRoles"></select-user-roles>
    <update-user-pwd ref="updateUserPwd"></update-user-pwd>
    <!-- 数据导入插件 -->
    <import-excel ref="importExcel"
                  upload-name="数据表配置导入"
                  :upload-key="pageOption.name"
                  :option="pageOption"
                  @importSuccess="refreshChange">

    </import-excel>
  </basic-container>
</template>

<script>
import {createStartMixin} from "@/mixins/start-crud.js"
import SelectUserRoles from "./SelectUserRoles";
import CustomTableColumns from "@/components/start-boot/columns/CustomTableColumns";
import updateUserPwd from "@/views/sys/user/updateUserPwd";
import ImportExcel from "@/components/common/ImportExcel";
const option={
  name: "sys/user"
}
export default {
  mixins:[createStartMixin(option)],
  components: {
    ImportExcel,
    SelectUserRoles,
    updateUserPwd,
    CustomTableColumns
  },
  methods: {
    rowUpdateBefore(row, index) {
      row.deptId = this.form.deptId

    },
    editUserRole(row) {
      this.$refs.selectUserRoles.show(row.userName)
    },
    editUserPwd(row) {
      this.$refs.updateUserPwd.show(row.id)
    }
  }
}
</script>

<style scoped>

</style>
